<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      position: relative;
      width: 700px;
      height: 400px;
      
      background-color: pink;
      font-size: 30px;
      text-align: center;
      color: white;
    }
    .close{
      position: absolute;
      width: 20px;
      height: 24px;
      right: 0;
      top: 1px;
      font-size: 20px;
      color: black;
      background-color: white;
      border: 1px solid black;
      box-shadow: 0 0 2px black;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="box">
    我是广告
    <div class="close">X</div>
  </div>
  <script>
    //获取对象
    const Close = document.querySelector(`.close`)
    const box = document.querySelector(`.box`)
    //添加监听
    Close.addEventListener('click', function () {
      box.style.display = 'none'
    })
  </script>
</body>
</html>